import { getUserInfo } from '../api/user'
export default {
  namespaced: true,
  state () {
    return {
      userInfo: {}
    }
  },
  mutations: {
    setUserInfo (state, obj) {
      state.userInfo = obj
    }
  },
  actions: {
    async UserInfo ({ commit }) {
      const res = await getUserInfo()
      commit('setUserInfo', res.data.data)
    }
  },
  getters: {
    textAvatar (state) {
      return state.userInfo.username ? state.userInfo.username.charAt(0).toUpperCase() : ''
    }
  }

}
